package org.dtrd.modules.device.config;

import io.swagger.annotations.ApiModel;

import java.util.Objects;

/**
 * 智能设备常量设定
 *
 * @author 萧
 * @date:2021-09-02 1:36 下午
 **/
public final class DeviceConstant {

    /**
     * 绑定状态
     */
    @ApiModel("绑定状态")
    public enum BindState {
        /**
         * 绑定
         */
        BIND(1),
        /**
         * 解绑
         */
        UNBIND(2);

        private int state;

        private BindState(int state) {
            this.state = state;
        }

        public int getState() {
            return state;
        }

        public void setState(int state) {
            this.state = state;
        }

        public static boolean isBind(int state) {
            return state == BIND.state;
        }
    }

    /**
     * 设备品牌
     */
    @ApiModel("设备品牌")
    public enum DeviceBrand {
        /**
         * 小糖医/掌护科技
         */
        XTY(1),
        /**
         * 爱奥乐
         */
        BIOLAND(2),
        /**
         * 微策
         */
        WEICE(3);

        private int brand;

        private DeviceBrand(int brand) {
            this.brand = brand;
        }

        public int getBrand() {
            return brand;
        }

        public void setBrand(int brand) {
            this.brand = brand;
        }

        public static boolean isXty(int brand) {
            return brand == XTY.brand;
        }

        public static boolean isBioland(int brand) {
            return brand == BIOLAND.brand;
        }

    }

    /**
     * 设备种类区分血糖仪或者血压计
     */
    @ApiModel("设备种类")
    public enum DeviceCategory {
        /**
         * 血压计
         */
        BLOODPRESSURE(1),
        /**
         * 血糖仪
         */
        BLOODSUGAR(2);

        private int category;

        private DeviceCategory(int category) {
            this.category = category;
        }

        public int getCategory() {
            return category;
        }

        public void setCategory(int category) {
            this.category = category;
        }

        public static boolean isSugar(Object type) {
            return Objects.equals(type, BLOODSUGAR.category);
        }

        public static boolean isBloodPressure(Object type) {
            return Objects.equals(type, BLOODPRESSURE.category);
        }
    }

    public static final class WeiceConfig {
        /**
         * 分配给第三方平台的校验码
         */
//        public static final String WEICE_SALT = "f2902UP19T3FM5O";
        public static final String WEICE_SALT = "c2A4z7Q3518x254";

        @ApiModel("记录时段")
        public enum TimeType {
            /**
             * 餐前
             */
            BEFOREMEALS(1),
            /**
             * 餐后
             */
            AFTERMEALS(2),
            /**
             * 空腹
             */
            LIMOSIS(4),
            /**
             * 凌晨
             */
            MORNING(8);

            private int type;

            private TimeType(int type) {
                this.type = type;
            }

            public int getType() {
                return type;
            }

            public void setType(int type) {
                this.type = type;
            }

        }


        @ApiModel("记录类型")
        public enum SampleType {
            /**
             * 血糖
             */
            SUGAR(1),
            /**
             * 血糖
             */
            GLU(2),
            /**
             * 血酮
             */
            KETONE(3),
            /**
             * 尿酸
             */
            URICACID(4);

            private int type;

            private SampleType(int type) {
                this.type = type;
            }

            public int getType() {
                return type;
            }

            public void setType(int type) {
                this.type = type;
            }

            public static boolean isSugarRecord(int sample) {
                return sample == SUGAR.type || sample == GLU.type;
            }

        }


    }


}
